﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Super.DomainService;
using Super.Entities;
using Super.Infrastructure;

namespace Super.Web.Areas.Admin.Controllers
{
    public class SettingController : BaseController
    {
        //
        // GET: /Admin/Setting/

        public ActionResult Index()
        {
            var adp = new DbContextAdapter();
            var model = CacheService.GetSetting();
            return View(model);
        }

        [HttpPost]
        public ActionResult Index(SettingInfo settingInfo)
        {
            var needCheck = Query.Post("needCheck");

            var adp = new DbContextAdapter();
            var settingService = new SettingService(adp);
            settingInfo.TopicCheck = needCheck != "False";
            settingService.UpdateSetting(settingInfo);
            adp.SaveChanges();

            PageTip(adp.ErrorMessage ?? "更改成功！");

            return View(settingInfo);

        }

       

    }
}
